package com.cljh.mapper;

import com.cljh.bean.Products;
import com.cljh.controller.page.UserPageBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductsMapper {
    @Insert("insert into mtmall_test.products (user_id, product_id, sum) values (#{products.userId},#{products.productId},#{products.sum});")
    int save(@Param("products") Products products);
    
    @Delete("delete from mtmall_test.products where id=#{id};")
    int delete(Integer id);


    int update(@Param("products") Products products);


    int selectByCount(@Param("products") UserPageBean products);


    int deleteByIds(@Param("ids") List<Integer> ids);

//    @Delete("delete from mtmall_test.products where id=#{id};")
    Products selectById(Integer id);



    List<Products> productsList();


    int saveAll(@Param("productss") List<Products> productss);

    List<Products> productsConditionList(@Param("begin")Integer begin, @Param("size") Integer size, @Param("products") UserPageBean products);

//    @Select("select * from mtmall_test.products where user_id=#{id} ;")
//    List<Products> selectByUserId(Integer id);

    @Delete("delete from mtmall_test.products where user_id=#{id};")
    int deleteByUserId(Integer id);

    List<Products> selectByUser(Integer id);

    Products selectByProducts(@Param("products")Products products);

    int deleteByUserAndProduct(@Param("userId") Integer userId,@Param("productId") Integer productId);
}
